<?
include("../Comm/Manage_err.php");
include("../Comm/Conn.php");

//新增
if($_GET['Action']=="Add"){
 $sql="insert into netsys_news_class (ClassName,ClassOrder) " .
  		"values ('$_POST[ClassName]','$_POST[ClassOrder]')";
    mysql_query($sql);
     echo "<script language='javascript'>"; 
     echo "alert('类别添加成功！');";
     echo " location='Netsys_Class_Set.php';"; 
     echo "</script>";

}

//修改
if($_GET['Action']=="Edit"){
     	$sql="update netsys_news_class set ClassName='".$_POST[ClassName]."',ClassOrder='".$_POST[ClassOrder]."' where ClassID=".htmlencode($_POST[ClassID])."" ;
		$query=mysql_query($sql);
		echo "<script language='javascript'>"; 
        echo "alert('类别修改成功！');";
        echo " location='Netsys_Class_Set.php';"; 
        echo "</script>";
}

//删除
if($_GET['Action']=="Del"){
$ClassID=htmlencode($_GET['ClassID']);

echo $sql ="delete from netsys_news_class where ClassID in ($ClassID)" ;
$result = mysql_query($sql);

echo "<script>";
echo "alert('您选择的信息已经被全部删除！');";
echo "location.href='Netsys_Class_Set.php';";
echo "</script>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Netsys网站管理系统</title>
<link href="../Style/Css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="10"></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="right_tittle">
  <tr>
    <td width="3"><img src="../images/r1.jpg" width="10" height="33" /></td>
    <td><img src="../images/current.jpg" width="9" height="9" /> 当前位置 &gt;&gt; 新闻管理 | 设置新闻类型</td>
    <td width="10" align="right"><img src="../images/r3.jpg" width="10" height="33" /></td>
  </tr>
</table>
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="2" class="right_con">
    <tr>
      <td height="490" align="center" valign="top" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="5"></td>
        </tr>
      </table>
      <br />
        <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDD8DF" class="table_all" >
          <tr class="table_tittle">
            <td bgcolor="#FFFFFF">编号</td>
            <td bgcolor="#FFFFFF">类型名称</td>
            <td bgcolor="#FFFFFF">排序</td>
            <td bgcolor="#FFFFFF">操作</td>
            <td bgcolor="#FFFFFF">删除</td>
          </tr>
        <?   
             $SQL="SELECT * FROM Netsys_News_Class order by ClassOrder Asc";
             $query=mysql_query($SQL);
			 $max=0;
			 $num=mysql_num_rows($query);
			 if($num!=0){
             while($row=mysql_fetch_array($query)){
        ?>
          <form name="MyForm" method="post" action="?Action=Edit&ClassID=<? echo $row['ClassID'];?>">
          <tr>
            <td bgcolor="#FFFFFF"><? echo $row['ClassID'];?></td>
            <td bgcolor="#FFFFFF"><input name="ClassName" type="text" value="<? echo $row['ClassName'];?>" size="50" maxlength="200"></td>
            <td bgcolor="#FFFFFF"><input name="ClassOrder" type="text" value="<? echo $row['ClassOrder'];?>" size="10" maxlength="5" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
            <td bgcolor="#FFFFFF"><input type="submit" name="Submit" value=" 提交修改 "></td>
            <td bgcolor="#FFFFFF"><a href="?Action=Del&ClassID=<? echo $row['ClassID'];?>" onClick="return confirm('您确定进行删除操作吗？该类别下所有信息将全部删除，无法恢复！')">删除</a></td>
          </tr>
          </form>
<?
  }
  }
  else
  {
?> 
          <tr>
            <td bgcolor="#FFFFFF" colspan="5" align="center">暂无信息，敬请期待！</td>
          </tr>
<?
}
?>
        </table>
      <br>
        <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDD8DF" class="table_all" >
          <tr class="table_tittle">
            <td bgcolor="#FFFFFF">编号</td>
            <td bgcolor="#FFFFFF">类型名称</td>
            <td bgcolor="#FFFFFF">排序</td>
            <td bgcolor="#FFFFFF">操作</td>
            <td bgcolor="#FFFFFF">删除</td>
          </tr>
          <form name="MyForm" method="post" action="?Action=Add">
          <tr>
            <td bgcolor="#FFFFFF"><? echo $num ;?></td>
            <td bgcolor="#FFFFFF"><input name="ClassName" type="text" value="" size="50" maxlength="200"></td>
            <td bgcolor="#FFFFFF"><input name="ClassOrder" type="text" value="<? echo $num ;?>" size="10" maxlength="5" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
            <td bgcolor="#FFFFFF"><input type="submit" name="Submit" value=" 确认提交 "></td>
            <td bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
          </form>
        </table>
      </td>
    </tr>
</table>
</body>
</html>